﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SaveCourse.aspx.cs" Inherits="CMSWCSFSolution.CMS.Views.SaveCourse"
    Title="SaveCourse" MasterPageFile="~/Shared/DefaultMaster.master" %>

<asp:Content ID="content" ContentPlaceHolderID="DefaultContent" runat="Server">
    <h1>
        SaveCourse</h1>
    <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-ui-1.8.24.custom.min.js" type="text/javascript"></script>
    <link href="../Styles/jquery-ui-1.8.24.custom.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/CMS_dialog.js" type="text/javascript"></script>
    <script type="text/javascript">

        function CourseNameValidation(source, arguments) {
            var CustomValidator1 = document.getElementById("CourseNameValidator");
            var value = document.getElementById("CourseNameTextBox").value;
            var patrn = /^[ A-Za-z]*$/;
            if (value == "") {
                arguments.IsValid = false;
                CustomValidator1.innerText = "Please input Course Name";
            }
            else if (value.length > 10) {
                arguments.IsValid = false;
                CustomValidator1.innerText = "Course Name must be less than 10 characters ";
            } else if (!patrn.exec(value)) {
                arguments.IsValid = false;
                CustomValidator1.innerText = " Illegal characters included";
            }
        }
        function TeacherValidation(source, arguments) {
            if (document.getElementById("TeacherDropDownList").value == "Please Select"
                ) {
                arguments.IsValid = false;
            } else {
                arguments.IsValid = true;
            }
        }
        function LevelValidation(source, arguments) {
            if (document.getElementById("CourseLevelDropDownList").value == "Please Select"
                ) {
                arguments.IsValid = false;
            } else {
                arguments.IsValid = true;
            }
        }
        function ReturnMainPage() {
            window.location.href = "CourseManage.aspx";
            return false;
        }

    </script>
    
   
    <div>
        <table>
            <tr style="height: 25px; width: 80%; margin-top: 10px">
                <td>
                    <asp:Label ID="title" runat="server" Text="" Style="height: 25px; width: 80%; margin-top: 40px"></asp:Label>
                </td>
            </tr>
        </table>
        &nbsp;<fieldset style="width: 600px">
            <legend>Course</legend>
            <table style="width: 100%; margin-left: 3%">
                <tr class="style4">
                    <td class="style3">
                        <asp:Label ID="Label2" runat="server" Text="Course Name" Style="margin-left: 10%"></asp:Label>
                    </td>
                    <td class="style2">
                        <asp:TextBox ID="CourseNameTextBox" runat="server" ClientIDMode="static" Style="margin-left: 8px"
                            Width="144px"></asp:TextBox>
                    </td>
                    <td class="style1">
                        <asp:CustomValidator ID="CourseNameValidator" runat="server" ClientIDMode="Static"
                            ForeColor="red" ControlToValidate="CourseNameTextBox" ValidateEmptyText="true"
                            ClientValidationFunction="CourseNameValidation"></asp:CustomValidator>
                    </td>
                </tr>
                <tr class="style4">
                    <td class="style3">
                        <asp:Label ID="Teacher" runat="server" Text="Teacher" Style="margin-left: 30px;"></asp:Label>
                    </td>
                    <td class="style2">
                        <asp:DropDownList ID="TeacherDropDownList" runat="server" ClientIDMode="Static" Style="margin-left: 9px"
                            Width="150px">
                            <asp:ListItem Text="Please Select"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td class="style1">
                        <asp:CustomValidator ID="TeacherValidator" runat="server" ClientIDMode="Static" ClientValidationFunction="TeacherValidation"
                            ControlToValidate="TeacherDropDownList" ForeColor="red" ValidateEmptyText="true"
                            ErrorMessage="Please select a Teacher"></asp:CustomValidator>
                    </td>
                </tr>
                <tr class="style4">
                    <td class="style3">
                        <asp:Label ID="CourseLevel" runat="server" Style="margin-left: 10%" Text="Course Level"></asp:Label>
                    </td>
                    <td class="style2">
                        <asp:DropDownList ID="CourseLevelDropDownList" runat="server" ClientIDMode="Static"
                            Style="margin-left: 9px" Width="150px">
                            <asp:ListItem Text="Please Select"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td class="style1">
                        <asp:CustomValidator ID="LevelValidator" runat="server" ClientIDMode="Static" ClientValidationFunction="LevelValidation"
                            ControlToValidate="CourseLevelDropDownList" ForeColor="red" ValidateEmptyText="true"
                            ErrorMessage="Please select a Level"></asp:CustomValidator>
                    </td>
                </tr>
                <tr>
                    <td class="style3">
                        <asp:Label ID="CourseStatus" runat="server" Style="margin-left: 10%" Text="Course Status"></asp:Label>
                    </td>
                    <td class="style2">
                        <asp:RadioButtonList ID="StatusRadioButtonList" runat="server" Style="margin-left: 20px"
                            RepeatDirection="Horizontal" RepeatLayout="Flow">
                            <asp:ListItem Value="True" Selected="true">Open</asp:ListItem>
                            <asp:ListItem Value="False">Closed</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
            </table>
            <fieldset style="width: 600px; margin-left: 20px">
                <legend>Student</legend>
                <table style="width: 100%; margin-top: 1%; margin-bottom: 10px;">
                    <tr class="style4">
                        <td class="style5">
                            <asp:Label ID="StudentList" runat="server" Style="margin-left: 40%" Text="Student List"></asp:Label>
                        </td>
                        <td class="style5">
                            <asp:Label ID="SelectedList" runat="server" Style="margin-left: 40%" Text="Selected List"></asp:Label>
                        </td>
                    </tr>
                </table>
                <table>
                    <tr style="width: 100%">
                        <td style="width: 40%">
                            <asp:ListBox ID="StudentListBox" runat="server" Height="320px" Style="margin-left: 40px;
                                margin-top: 16px" Width="240px" SelectionMode="Multiple"></asp:ListBox>
                        </td>
                        <td style="width: 20%">
                            <asp:Button ID="Button2" runat="server" OnClick="add_Click" Style="position: absolute;
                                z-index: 1; margin-left: 20px; top: 550px;" Text="&gt;&gt;" Width="96px" CausesValidation="False" />
                            <asp:Button ID="Remove" runat="server" OnClick="Remove_Click" Style="position: absolute;
                                z-index: 2; margin-left: 20px; top: 620px;" Text="&lt;&lt;" Width="96px" CausesValidation="False" />
                        </td>
                        <td style="width: 40%">
                            <asp:ListBox ID="SelectedListBox" runat="server" Height="320px" Style="margin-left: 10px;
                                margin-top: 16px" Width="240px" SelectionMode="Multiple"></asp:ListBox>
                        </td>
                    </tr>
                </table>
            </fieldset>
            <table style="width: 100%">
                <tr class="style4">
                    <td class="style6">
                        <asp:Button ID="Save" runat="server" Height="32px" OnClick="Save_Click" Style="margin-left: 50px;
                            margin-top: 10px" Text="Save Course" Width="90px" />
                    </td>
                    <td class="style5">
                        &nbsp;<input type="button" value="Return" onclick="ReturnMainPage();" text="Return"
                            style="width: 90px; height: 31px; margin-left: 50px; margin-top: 10px" />
                    </td>
                </tr>
            </table>
            &nbsp;<br />
        </fieldset>
    </div>
    <style type="text/css">
        .style1
        {
            height: 25px;
            width: 65%;
        }
        .style2
        {
            height: 25px;
            width: 20%;
        }
        .style3
        {
            height: 25px;
            width: 15%;
        }
        .style4
        {
            width: 800px;
            margin-left: 20px;
            height: 30px;
        }
        .style5
        {
            width: 50%;
            margin-left: 20px;
            height: 30px;
        }
        .style6
        {
            width: 11%;
            margin-left: 20px;
            height: 30px;
        }
    </style>
</asp:Content>
